﻿using PLCS.Domain.Shared.Orders;

namespace PLCS.Domain.Orders;

public class HisOrder : BaseEntity
{
    /// <summary>
    /// 编号
    /// </summary>
    public string UpperNo { get; set; }

    /// <summary>
    /// 线体编码
    /// </summary>
    public string PdLineNo { get; set; }

    /// <summary>
    /// 托盘编号
    /// </summary>
    public string TrayNo { get; set; }

    /// <summary>
    /// 工单号
    /// </summary>
    public string OrderNo { get; set; }

    public string SolutionNo { get; set; }

    /// <summary>
    /// 工单类型
    /// </summary>
    public OrderType OrderType { get; set; }

    public string OnlineStation { get; set; }

    /// <summary>
    /// 计划开始时间
    /// </summary>
    ///
    public DateTime PlanStartTime { get; set; }

    /// <summary>
    /// 计划结束时间
    /// </summary>
    ///
    public DateTime PlanEndTime { get; set; }

    /// <summary>
    /// 实际开始时间
    /// </summary>
    ///
    public DateTime FactStartTime { get; set; }

    /// <summary>
    /// 实际结束时间
    /// </summary>
    public DateTime FactEndTime { get; set; }

    /// <summary>
    /// 工单状态
    /// </summary>
    ///
    public OrderStatus Status { get; set; }

    [NotMapped]
    public List<OrderRunningCondition>? OrderRunningConditions { get; set; }

    private HisOrder()
    {
    }

    public HisOrder(string pdLineNo, string trayNo, string orderNo, OrderType orderType, string onlineStation, DateTime planStartTime, DateTime planEndTime, DateTime factStartTime, string solutionNo, string upperNo)
    {
        PdLineNo = pdLineNo;
        TrayNo = trayNo;
        OrderNo = orderNo;
        OrderType = orderType;
        OnlineStation = onlineStation;
        PlanStartTime = planStartTime;
        PlanEndTime = planEndTime;
        SolutionNo = solutionNo;
        UpperNo = upperNo;
        FactStartTime = factStartTime;
        FactEndTime = DateTime.Now;
        Status = OrderStatus.执行完成;
    }
}